<div id="wrapMain">
            <div class="wrap_1024" style="margin-bottom:40px">
             <div class="btn-group btn-group-justified">
        <a href="index.php?module=user&act=post_video" class="btn btn-danger">	<h3>Video</h3>
                                                            <i class="icon-facetime-video icon-3x"></i> <br/>
                                                           </a>
        <a href="index.php?module=user&act=post_image" class="btn btn-info">	<h3>Hình Ảnh</h3>
                                                            <i class="icon-picture icon-3x"></i> <br/>
                                                           </a>
        <a href="index.php?module=user&act=post_text" class="btn btn-success"> <h3>Bài Viết</h3>
                                                            <i class="icon-file-text icon-3x"></i> <Br/>
                                                          
                                                            </a>
      
      </div>
      <bR/>
      <bR/>
            <div class='head_nav'><span class="icon-picture"></span> ĐĂNG VIDEO</div>
            <div class="user_profile">
				
				<div class="row" >
					<div class="col-md-12 ">
						<div id="contentIndex" class="col-md-12">
										<div role="dialog" id="modalAlertBox" class="modal fade" style="display: none;">
											<div class="modal-dialog modal-wide">
												<div class="modal-content">
													<div class="modal-header">
														<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
														<h4 class="modal-title"></h4>
													</div>
											        <div class="modal-body">
														
														<div style="clear:both"></div>
											        </div>
												</div><!-- /.modal-content -->
											</div>
										</div>
										
										<div id="wrapLoadMoreItems">
											<div class="normalLoadBtn" id="loadMoreItems"><img width="20" alt="loading" src="public/images/loading.gif"> Loading </div><br>
										</div>
										<div class="formLoading"></div>
										
									
									    
									    <div class="generalError" style="display: none;"></div>
									    <form id="videoUpload" class="userPostForm" role="form" method="post" enctype="multipart/form-data">
											
					
											<div class="form-group">
												<div class="row">
                                                <div class="col-md-2">
												<label for="txtTitle">Tiêu đề</label>
                                                </div>
                                                <div class="col-md-10">
												<input type="text" class="form-control" id="txtTitle" placeholder="Nhập tiêu đề...">
                                                </div>
                                                </div>
											</div>
											
											<div class="form-group">
												<div class="row">
                                                <div class="col-md-2">
												<label for="txtDescription">Giới thiệu</label>
                                                </div>
                                                <div class="col-md-10">
												<textarea class="form-control" placeholder="Nhập mô tả..." id="txtDescription" rows="5"></textarea>
												</div>
                                                </div>
                                            </div>
                                            
                                            <div class="form-group">
												<div class="row">
                                                <div class="col-md-2">
												<label for="txtSource">Nguồn</label>
                                                </div>
                                                <div class="col-md-2">
													<select id="txtSource">
														
														<option value="youtube">Youtube</option>	
														<option value="abc">abc</option>	
														
													</select>
												</div>
												<div class="col-md-8">
													<input id="txtSourceUrl" type="" name="" class="form-control"  placeholder="Url..." />
												</div>
                                                </div>
                                            </div>
												
											<?php if($data['categories']):?>
											<div class="form-group">
                                            	<div class="row">
                                                <div class="col-md-2">
												<label for="txtCat">Chọn danh mục</label>
                                                </div>
                                                <div class="col-md-10">
												<select id="txtCat" class="myNormalSelect select2">
													<?php foreach($data['categories'] as $value): ?>
													<option value="<?= $value['id']; ?>"><?= $value['name'] ?></option>	
													<?php endforeach; ?>
												</select>
                                                </div>
                                                </div>
											</div>
											<?php endif;?>
											
											<div class="form-group">
                                            	<div class="row">
                                                <div class="col-md-2">
												<label for="txtAlbum">Chọn Album</label>
                                                </div>
                                                <div class="col-md-10">
												<select id="txtAlbum" class="myNormalSelect select2">
                                                <option value="">Tùy Chọn Album</option>	
													<?php if($data['albums']):?>
													<?php foreach($data['albums'] as $value): ?>
													<option value="<?= $value['id']; ?>"><?= $value['name'] ?></option>	
													<?php endforeach; ?>
													<?php endif;?>
												</select>
												
												<button type="submit" class="btn btn-sm createAlbum">
							                    	<i class="glyphicon glyphicon-plus"></i>
								                    <span>Tạo Album mới</span>
								                </button>
                                                </div>
                                                </div>
											</div>
											<br />
                                            
                                       
                                          
                                           
                                                
                                            <div class="row"> <!-- Start class row wrap upload image and submit button -->
                                            <div class="col-md-2">
                                            </div>
                                            <div class="col-md-10">
											<button type=submit class="btn btn-primary mySubmit" id="submitVideo">
							                    <i class="glyphicon glyphicon-hand-up"></i>
							                    <span>Đăng bài</span>
							                </button>
                                            </div> <!-- End of class col-md-10 wrap upload image and submit button -->
                                            </div><!-- End of class row wrap upload image and submit button -->
											
										</form>
				
						</div><!-- end #contentIndex -->
					</div>
					
					
				</div> <!-- End of row -->
			</div><!-- end wrap_1024 -->
		</div><!-- end wrapMain -->
		
<!-- end #wrapMain -->		
		

<script type="text/javascript">
	$(document).ready(function(){
		
		
	    $('.createAlbum').click(function(e){
		    e.preventDefault();
		    $('#txtAlbum_message').remove();
		    $('#modalAlbumBox').remove();
		    var that = this;
			$.ajax({
				url : "<?php echo BASE_URL ?>index.php?module=user&act=ajax&albumBox=1",
				success : function(data){
					$('.createAlbum').parent().append(data);
					$('.createAlbum').parent().find('#modalAlbumBox').modal();
				},
			});
		});

	    $('#txtTitle').blur(function(){
	    	$.ajax({
	    		url: "index.php?module=user&act=ajax&validateTitle=1",
	    		type: 'POST',
	    		data: {txtTitle: $('#txtTitle').val()},
	    		success: function(data){
	    			newData = $.parseJSON(data);
	    			if(newData.errors){
		    			
		    			if($('#txtTitle_error').length <= 0){
			    		
		    				$('#txtTitle').parent().append('<div id="txtTitle_error" class="alert alert-danger alert-dismissable" style="display: none;"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+newData.errors.txtTitle+'</div>');
		    				$('#txtTitle_error').slideDown('fast');
		    			}else{
							$('#txtTitle_error').html(newData.errors.txtTitle);
		    			}
	    				
	    			}else{
	    				$('#txtTitle_error').remove();
	    			}
	    		}
	    	});
	    });

	    $('#txtDescription').blur(function(){
	    	//$(this).parent().find('.alert').remove();
	    	$.ajax({
	    		url: "index.php?module=user&act=ajax&validateDescription=1",
	    		type: 'POST',
	    		data: {txtDescription: $('#txtDescription').val()},
	    		success: function(data){
	    			newData = $.parseJSON(data);
	    			console.log(newData);
	    			if(newData.errors.txtDescription){
	    				if($('#txtDescription_error').length <= 0){
		    				$('#txtDescription').parent().append('<div id="txtDescription_error" class="alert alert-danger alert-dismissable" style="display: none;"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+newData.errors.txtDescription+'</div>');
		    				$('#txtDescription_error').slideDown('fast');
	    				}else{
							$('#txtDescription_error').html(newData.errors.txtDescription);
		    			}
	    			}else{
	    				$('#txtDescription_error').remove();
	    			}
	    		}
	    	});
	    });

	    /*
	     * Submit event
	     */
	    $('button#submitVideo').click(function(e){
	    	e.preventDefault();
	    	$(".alert").remove();
	  		$('.userPostForm').css('opacity', '0.3');
			$('.formLoading')
			.css('width', $('#videoUpload').width())
			.css('height', $('#videoUpload').height())
			.css('opacity', '1')
			.css('z-index','9999').css('display', 'block');
			$('#wrapLoadMoreItems').css('display', 'block').center();

	    	$.ajax({
	    		url : "<?php echo BASE_URL; ?>index.php?module=user&act=ajax&validatePostVideo=1",
	    		type : 'POST',
	    		
	    		data : {
	    			txtTitle: $('#txtTitle').val(), 
	    			txtDescription : $('#txtDescription').val(), 
	    			txtCat : $('#txtCat').val(),
	    			txtAlbum : $('#txtAlbum').val(),
	    			txtSource: $('#txtSource').val(),
	    			txtSourceUrl: $('#txtSourceUrl').val()
	    		},
	    		
	    		success : function(data){

	    			$('.formLoading').css('display', 'none');
	    			$('#wrapLoadMoreItems').css('display', 'none');
	    			$('.userPostForm').css('opacity', '1');
	    			if(data) newData = $.parseJSON(data);
	    			if(newData.errors){
	    				$.each(newData.errors, function(e, error){
		    				if(e != 'error'){
		    					$('#' + e).parent().append('<div id="'+e+'_error" class="alert alert-danger alert-dismissable" style="display: none;"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+error+'</div>');
		    					$('#' + e + '_error').slideDown('fast');
		    				}
	    				});
	    			}else{
	    				popupMessage('Thành công', <?= json_encode(array('Đăng bài thành công.')); ?>, 'alert-success');
		    			$('#popup_message').prepend('<div class="loading" id="mainLoading"><div id="loadMoreItems" class="normalLoadBtn"><img width="20" src="public/images/loading.gif" alt="loading" /> Loading </div><div class="clr"></div></div>');
		    			$('#mainLoading').delay(1500).slideUp(function(){
							window.location.href = '<?= UPLOAD ?>/video';
			    		});
	    			}
	    		}
	    	});
	    });

	   
	    
	    $('.select2').select2({ width: '250' });
		$('#txtSource').select2({width: '150'});
	});
</script>

<script src="public/exts/js/jquery.center.js"></script>
